class Solution
{
public:
    int maxArea(vector<int>& height)
    {
        int left = 0, right = height.size() - 1;
        int ans = 0;
        while (left < right)
        {
            int area = (right - left) * min(height[left], height[right]);
            ans = max(area, ans);
            if (height[left] < height[right])
            {
                left += 1;
            }
            else
            {
                right -= 1;
            }
        }
        return ans;
    }
};